package com.example.demo.pojos;

import javax.persistence.*;
import java.util.List;
import java.util.Objects;

@Entity
public class Pdtype {
    private int typeId;
    private String typeName;
    private String details;
    private List<Product> cp;

    @Id
    @Column(name = "type_id", nullable = false)
    public int getTypeId() {
        return typeId;
    }

    public void setTypeId(int typeId) {
        this.typeId = typeId;
    }

    @Basic
    @Column(name = "type_name", nullable = true, length = 255)
    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    @Basic
    @Column(name = "details", nullable = true, length = 255)
    public String getDetails() {
        return details;
    }

    public void setDetails(String details) {
        this.details = details;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pdtype pdtype = (Pdtype) o;
        return typeId == pdtype.typeId &&
                Objects.equals(typeName, pdtype.typeName) &&
                Objects.equals(details, pdtype.details);
    }

    @Override
    public int hashCode() {
        return Objects.hash(typeId, typeName, details);
    }

    @OneToMany(mappedBy = "cpfl")
    public List<Product> getCp() {
        return cp;
    }

    public void setCp(List<Product> cp) {
        this.cp = cp;
    }
}
